library(lavaan)
##Prepare data with sufficient statisitics##
mymeans<-matrix(c(3.06893, 2.92590, 3.11013), ncol=3,nrow=1)
mysd<-c(0.84194,0.88934,0.83470)
mat <- c(1.00000,
0.55226, 1.00000,
0.56256, 0.66307, 1.00000)
mycor <- getCov(mat, lower = TRUE)
##Transform correlation matrix to covariance matrix using information above##
myvarcov <- outer(mysd, mysd, FUN="*")
mycov <- mycor * myvarcov
rownames(mycor) <-c( "Glad", "Cheerful", "Happy")
colnames(mycor) <-c( "Glad", "Cheerful", "Happy")
rownames(mycov) <-c( "Glad", "Cheerful", "Happy")
colnames(mycov) <-c( "Glad", "Cheerful", "Happy")
mynob<-823
| Glad | Cheerful | Happy | |
|---|---|---|---|
| Glad | 1.00 | 0.55 | 0.56 |
\[ \Sigma = \Lambda \Psi \Lambda + \Theta \tag{1} \]
# Mplus file
l.cheer.inp
using correlations only (instead of variance/covariance matirx)
Found more than one class "Model" in cache; using the first, from namespace 'MatrixModels'
lavaan (0.5-20) converged normally after 9 iterations
Number of observations 823
Estimator ML
Minimum Function Test Statistic 0.000
Degrees of freedom 0
Model test baseline model:
Minimum Function Test Statistic 0.000
Degrees of freedom 0
P-value NA
User model versus baseline model:
Comparative Fit Index (CFI) 1.000
Tucker-Lewis Index (TLI) 1.000
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -1070.768
Loglikelihood unrestricted model (H1) -1070.768
Number of free parameters 1
Akaike (AIC) 2143.536
Bayesian (BIC) 2148.249
Sample-size adjusted Bayesian (BIC) 2145.074
Root Mean Square Error of Approximation:
RMSEA 0.000
90 Percent Confidence Interval 0.000 0.000
P-value RMSEA <= 0.05 1.000
Standardized Root Mean Square Residual:
SRMR 0.000
Parameter Estimates:
Information Expected
Standard Errors Standard
Latent Variables:
Estimate Std.Err Z-value P(>|z|)
Positive =~
Cheerful 1.000
Variances:
Estimate Std.Err Z-value P(>|z|)
Positive 0.790 0.039 20.285 0.000
Cheerful 0.000
cat(file = 'topics/2_MeasurementModel/2b_ConfirmatoryFactorAnalysis/mplus/l.cheer.out')